<table>
	<tr>
		<td id="register_items_container">
			<table id="title_section">
				<tr>
					<td id="title_icon">
						<img src='https://demo.phppointofsale.com/images/menubar/sales.png' alt='title icon' />
					</td>
					<td id="title">
						Sales Register					</td>
					<td id="register_wrapper">
						<form action="https://demo.phppointofsale.com/index.php/sales/change_mode" method="post" accept-charset="utf-8" id="mode_form">						<span>Register Mode</span>
						<select name="mode" id="mode">
<option value="sale" selected="selected">Sale</option>
<option value="return">Return</option>
</select>						</form>
					</td>
					<td id="show_suspended_sales_button">
						<a href="https://demo.phppointofsale.com/index.php/sales/suspended/width~550" class="thickbox none" title="Suspended Sales"><div class='small_button'>Suspended Sales</div></a>					</td>
				</tr>
			</table>
			<div id="reg_item_search">
				<form action="https://demo.phppointofsale.com/index.php/sales/add" method="post" accept-charset="utf-8" id="add_item_form">					<input type="text" name="item" value="" id="item" size="40" accesskey="i"  />					<div id="new_item_button_register" >
						<a href="https://demo.phppointofsale.com/index.php/items/view/-1/width~550" class="thickbox none" title="New Item"><div class='small_button'><span>New Item</span></div></a>					</div>
				</form>
			</div>
			<div id="register_holder">
			<table id="register">

				<thead>
					<tr>
						<th id="reg_item_del"></th>
						<th id="reg_item_name">Item Name</th>
						<th id="reg_item_number">Item #</th>
						<th id="reg_item_stock">Stock</th>
						<th id="reg_item_price">Price</th>
						<th id="reg_item_qty">Qty.</th>
						<th id="reg_item_discount">Disc %</th>
						<th id="reg_item_total">Total</th>
					</tr>
				</thead>
				<tbody id="cart_contents">
												<tr>
								<td colspan='8'>
								<form action="https://demo.phppointofsale.com/index.php/sales/edit_item/4" method="post" accept-charset="utf-8" class="line_item_form">
									<table>

											<tr id="reg_item_top">
												<td id="reg_item_del" ><a href="https://demo.phppointofsale.com/index.php/sales/delete_item/4" class="delete_item">Delete</a></td>
												<td id="reg_item_name">a2</td>
												<td id="reg_item_number">123</td>
												<td id="reg_item_stock" >123120.00</td>

																								<td id="reg_item_price"><input type="text" name="price" value="13123.00" size="6" id="price_4"  /></td>

												<td id="reg_item_qty">
												<input type="text" name="quantity" value="1" size="2" id="quantity_4"  />												</td>

												<td id="reg_item_discount"><input type="text" name="discount" value="0" size="3" id="discount_4"  /></td>
												<td id="reg_item_total">$13,123.00</td>
											</tr>

											<tr id="reg_item_bottom">
												<td id="reg_item_descrip_label">Desc:</td>
												<td id="reg_item_descrip" colspan="4">
													None
<input type="hidden" name="description" value="" />
												</td>
												<td id="reg_item_serial_label">
																									</td>
												<td id="reg_item_serial" colspan="2">

<input type="hidden" name="serialnumber" value="" />
												</td>
											</tr>
									</table>
								</form>
							</tr>
						</td>
													<tr>
								<td colspan='8'>
								<form action="https://demo.phppointofsale.com/index.php/sales/edit_item/3" method="post" accept-charset="utf-8" class="line_item_form">
									<table>

											<tr id="reg_item_top">
												<td id="reg_item_del" ><a href="https://demo.phppointofsale.com/index.php/sales/delete_item/3" class="delete_item">Delete</a></td>
												<td id="reg_item_name">car</td>
												<td id="reg_item_number">12345</td>
												<td id="reg_item_stock" >192.00</td>

																								<td id="reg_item_price"><input type="text" name="price" value="12000.00" size="6" id="price_3"  /></td>

												<td id="reg_item_qty">
												1
<input type="hidden" name="quantity" value="1" />
												</td>

												<td id="reg_item_discount"><input type="text" name="discount" value="0" size="3" id="discount_3"  /></td>
												<td id="reg_item_total">$12,000.00</td>
											</tr>

											<tr id="reg_item_bottom">
												<td id="reg_item_descrip_label">Desc:</td>
												<td id="reg_item_descrip" colspan="4">
													<input type="text" name="description" value="" size="20" id="description_3"  />												</td>
												<td id="reg_item_serial_label">
													Serial:												</td>
												<td id="reg_item_serial" colspan="2">
													<input type="text" name="serialnumber" value="" size="20" id="serialnumber_3"  />												</td>
											</tr>
									</table>
								</form>
							</tr>
						</td>
											</tbody>
				</table>
			</div>

			<div id="reg_item_base"></div>
					</td>
		<td style="width:8px;"></td>
		<td id="over_all_sale_container">
			<div id="overall_sale">

				<div id="suspend_cancel">
					<div id="suspend" style='visibility: visible;'>
														<div class='small_button' id='suspend_sale_button'>
									<span>Suspend Sale</span>
								</div>
											</div>
					<div id="cancel" style='visibility: visible;'>
													<form action="https://demo.phppointofsale.com/index.php/sales/cancel_sale" method="post" accept-charset="utf-8" id="cancel_sale_form">								<div class='small_button' id='cancel_sale_button'>
									<span>Cancel Sale</span>
								</div>
							</form>
											</div>
				</div>

				<div id="customer_info_shell">
					<div id='customer_info_filled'><div id="customer_name">sample customer 1</div><div id="customer_email"></div><div id="customer_edit"><a href="https://demo.phppointofsale.com/index.php/customers/view/1847/width~550" class="thickbox none" title="Update Customer">Edit</a></div><div id="customer_remove"><a href="https://demo.phppointofsale.com/index.php/sales/delete_customer" id="delete_customer">Detach</a></div></div>				</div>

				<div id='sale_details'>
					<table id="sales_items">
						<tr>
							<td class="left">Items In Cart:</td>
							<td class="right">2</td>
						</tr>
																									<tr>
							<td class="left">Sub Total:</td>
							<td class="right">$25,123.00</td>
						</tr>
											</table>
					<table id="sales_items_total">
						<tr>
							<td class="left">Total:</td>
							<td class="right">$25,123.00</td>
						</tr>
					</table>
				</div>


					<div id="Payment_Types" >

													<table id="register">
							<thead>
							<tr>
							<th id="pt_delete"></th>
							<th id="pt_type">Type</th>
							<th id="pt_amount">Amount</th>


							</tr>
							</thead>
							<tbody id="payment_contents">
							<form action="https://demo.phppointofsale.com/index.php/sales/edit_payment/Cash" method="post" accept-charset="utf-8" id="edit_payment_formCash">								<tr>
								<td id="pt_delete"><a href="https://demo.phppointofsale.com/index.php/sales/delete_payment/Cash" class="delete_payment">[Delete]</a></td>


								<td id="pt_type">Cash </td>
								<td id="pt_amount">$12,022.00  </td>


								</tr>
								</form>
															</tbody>
							</table>

						<table id="amount_due">
						<tr class="">
							<td>
								<div class="float_left" style="font-size:.8em;">Amount Due:</div>
							</td>
							<td style="text-align:right; ">
								<div class="float_left" style="text-align:right;font-weight:bold;">$13,101.00</div>
							</td>
						</tr>
					</table>

						<div id="make_payment">
							<form action="https://demo.phppointofsale.com/index.php/sales/add_payment" method="post" accept-charset="utf-8" id="add_payment_form">							<table id="make_payment_table">
								<tr id="mpt_top">
									<td id="add_payment_text">
										Add Payment:
									</td>
									<td>
										<select name="payment_type" id="payment_types">
<option value="Cash">Cash</option>
<option value="Check">Check</option>
<option value="Gift Card">Gift Card</option>
<option value="Debit Card">Debit Card</option>
<option value="Credit Card">Credit Card</option>
</select>									</td>
								</tr>
								<tr id="mpt_bottom">
									<td id="tender" colspan="2">
										<input type="text" name="amount_tendered" value="13101.00" id="amount_tendered" size="10" accesskey="p"  />									</td>
								</tr>
							</table>
							<div class='small_button' id='add_payment_button'>
								<span>Add Payment</span>
							</div>
							</form>
						</div>
					</div>

											<div id="finish_sale">
							<form action="https://demo.phppointofsale.com/index.php/sales/complete" method="post" accept-charset="utf-8" id="finish_sale_form">													</div>
					</form>




			</div><!-- END OVERALL-->
		</td>
	</tr>
</table>

<div id="feedback_bar"></div>

<script type="text/javascript">
</script>

<script type="text/javascript" language="javascript">
$(document).ready(function()
{
	var my_ar = new Array ("reg_item_total","reg_item_discount", "reg_item_qty", "reg_item_price", "reg_item_stock", "reg_item_number", "reg_item_name", "reg_item_del");
	for (i=0; i < my_ar.length; i++ )
	{
		my_th = $("th#" + my_ar[i]);
		my_td = $("td#" + my_ar[i]);
		my_td.each(function (i)
		{
			$(this).width(my_th.width());
		});
	}

 	$('a.thickbox, area.thickbox, input.thickbox').each(function(i)
	{
		$(this).unbind('click');
    });

	tb_init('a.thickbox, area.thickbox, input.thickbox');

	$('#add_item_form, #mode_form, #select_customer_form, #add_payment_form').ajaxForm({target: "#register_container"});

	$("#cart_contents input").change(function()
	{
		var toFocusId = $(":input[type!=hidden]:eq("+($(":input[type!=hidden]").index(this) + 1) +")").attr('id');
		$(this.form).ajaxSubmit({target: "#register_container", success: function()
		{
			$('#' + toFocusId).focus();
		}
		});
	});

	$( "#item" ).autocomplete({
		source: 'https://demo.phppointofsale.com/index.php/sales/item_search',
		delay: 10,
		autoFocus: false,
		minLength: 0,
		select: function(event, ui)
		{
 			event.preventDefault();
 			$( "#item" ).val(ui.item.value);
			$('#add_item_form').ajaxSubmit({target: "#register_container"});
		},
		change: function(event, ui)
		{
			if ($(this).attr('value') != '' && $(this).attr('value') != "Type item name or scan barcode...")
			{
				$("#add_item_form").ajaxSubmit({target: "#register_container"});
			}

    		$(this).attr('value',"Type item name or scan barcode...");
		}
	});

	$('#item').focus();

	$('#item,#customer').click(function()
    {
    	$(this).attr('value','');
    });

	$( "#customer" ).autocomplete({
		source: 'https://demo.phppointofsale.com/index.php/sales/customer_search',
		delay: 10,
		autoFocus: false,
		minLength: 0,
		select: function(event, ui)
		{
			$("#customer").val(ui.item.value);
			$('#select_customer_form').ajaxSubmit({target: "#register_container"});
		}
	});

    $('#customer').blur(function()
    {
    	$(this).attr('value',"Type customer name...");
    });

	$('#comment').change(function()
	{
		$.post('https://demo.phppointofsale.com/index.php/sales/set_comment', {comment: $('#comment').val()});
	});

	$('#email_receipt').change(function()
	{
		$.post('https://demo.phppointofsale.com/index.php/sales/set_email_receipt', {email_receipt: $('#email_receipt').is(':checked') ? '1' : '0'});
	});


    $("#finish_sale_button").click(function()
    {
    	if (confirm('Are you sure you want to submit this sale? This cannot be undone.'))
    	{
    		$('#finish_sale_form').submit();
    	}
    });

	$("#suspend_sale_button").click(function()
	{
		if (confirm('Are you sure you want to suspend this sale?'))
    	{
			$("#register_container").load('https://demo.phppointofsale.com/index.php/sales/suspend');
    	}
	});

    $("#cancel_sale_button").click(function()
    {
    	if (confirm('Are you sure you want to clear this sale? All items will cleared.'))
    	{
			$('#cancel_sale_form').ajaxSubmit({target: "#register_container"});
    	}
    });

	$("#add_payment_button").click(function()
	{
		$('#add_payment_form').ajaxSubmit({target: "#register_container"});
    });

	$("#payment_types").change(checkPaymentTypeGiftcard).ready(checkPaymentTypeGiftcard);
	$('#mode').change(function()
	{
		$('#mode_form').ajaxSubmit({target: "#register_container"});
	});

	$('.delete_item, .delete_payment, #delete_customer').click(function(event)
	{
		event.preventDefault();
		$("#register_container").load($(this).attr('href'));
	});
});

function post_item_form_submit(response)
{
	if(response.success)
	{
		$("#item").attr("value",response.item_id);
		$('#add_item_form').ajaxSubmit({target: "#register_container"});

	}
}

function post_person_form_submit(response)
{
	if(response.success)
	{
		if ($("#select_customer_form").length == 1)
		{
			$("#customer").attr("value",response.person_id);
			$('#select_customer_form').ajaxSubmit({target: "#register_container"});
		}
		else
		{
			$("#register_container").load('https://demo.phppointofsale.com/index.php/sales/reload');
		}
	}
}

function checkPaymentTypeGiftcard()
{
	if ($("#payment_types").val() == "Gift Card")
	{
		$("#amount_tendered_label").html("Gift Card Number");
		$("#amount_tendered").val('');
		$("#amount_tendered").focus();
	}
	else
	{
		$("#amount_tendered_label").html("Amount Tendered");
	}
}

</script>